import {Bookmark, BookmarkObj} from "@/utils/bookmarkUtils";

const popupPageStatStoreKey = "popupStateToSave";
const bookmarkStoreKey = "bookmarkStoreKey";

const configStoreKey = "configStoreKey";

const initBrowserError = Error("浏览器驱动未初始化。");

const onedrive = "onedrive";

const serviceTitleMap = {
    onedrive: "OneDrive",
};

const zhCn = "zh-cn";


interface PageState {
    bookmark?: string | Bookmark[];
    filterText?: string;
    tree?: any;
    defaultExpandedKeys: string[];
}


interface Option {
    value: any;
    label: string;
    disable?: boolean
}


interface Message {
    type: MsgType
    data: any,
}


interface SyncServiceSettingObj {
    enable?: boolean,
    token?: string | undefined | null;
    syncMethod?: string;
    cronSyncTime?: number | null;
}


interface ConfigObj {
    isCollapsedWhenBookmarkTreeNullSearch: boolean;
    browserType: BrowserType;
    isStoreBookmarkExpandStatus: boolean;
    isShowAffix: boolean;
    language: string;
    urlOpenType: string;
    importBookmarkType: string;
    syncServiceSettingMap?: Record<string, SyncServiceSettingObj>;
    watchBookmarkChange: boolean;
}


enum UrlOpenType {
    currentTab = "在当前页打开链接",
    newTab = "在新标签页打开链接",
    hideWindow = "在隐身窗口打开链接",
    newWindow = "在新窗口打开链接",
    default = newTab,
}


enum BrowserType {
    chrome = "Chrome",
    qqbrowser = "qqbrowser",
    edge = "Edge",
    firefox = "Firefox",
    chromium = "Chromium",
    browser360 = "Browser360",
    safari = "Safari",
    default = chrome,
}


enum Language {
    "zh-cn" = "简体中文",
    en = "英语",
    default = "简体中文",
}

enum ImportBookmarkType {
    merge = "合并",
    cover = "覆盖",
    default = merge,
}


enum SyncMethod {
    none = "不同步",
    cron = "定时同步",
    sync = "实时同步",
    default = none,
}

/**
 * 消息类型
 */
enum MsgType {
    // 更新定时时间
    updateCronTime = "updateCronTime",
    // 更新同步方式
    updateSyncMethod = "updateSyncMethod",
    // 停止同步服务
    stopSyncService = "stopSyncService",
    default = stopSyncService,
}


export {
    BrowserType, popupPageStatStoreKey, configStoreKey, initBrowserError, UrlOpenType, PageState, Language,
    ImportBookmarkType, SyncMethod, onedrive, serviceTitleMap, MsgType, Message, SyncServiceSettingObj, ConfigObj,
    Option, bookmarkStoreKey
};

